package com.xiejun.netty;

import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.channels.SocketChannel;

/**
 * Channel处理器接口
 */
public interface ChannelHandler {
    
    /**
     * 处理通道读事件
     * @param channel Socket通道
     * @param buffer 读取到的数据缓冲区
     * @throws IOException IO异常
     */
    void channelRead(SocketChannel channel, ByteBuffer buffer) throws IOException;
    
    /**
     * 处理通道连接事件
     * @param channel Socket通道
     * @throws IOException IO异常
     */
    void channelConnected(SocketChannel channel) throws IOException;
    
    /**
     * 处理通道断开连接事件
     * @param channel Socket通道
     * @throws IOException IO异常
     */
    void channelDisconnected(SocketChannel channel) throws IOException;
}